/**
 * 
 */
package com.dream.house.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.com.servyou.base.exception.DAOException;

import com.dream.house.dao.RoomDAO;
import com.dream.house.dao.base.HouseBaseDAO;
import com.dream.house.entity.RoomDTO;

/**
 * 房信息DAO操作
 * @author ahk
 * @since 1.0
 */
public class RoomDAOImpl extends HouseBaseDAO implements RoomDAO {

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RoomDAO#saveRoom(com.dream.house.entity.RoomDTO)
	 */
	@Override
	public boolean saveRoom(RoomDTO dto) throws DAOException {
		
		return createEntity("saveRoom", dto);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RoomDAO#updateRoom(com.dream.house.entity.RoomDTO)
	 */
	@Override
	public boolean updateRoom(RoomDTO dto) throws DAOException {
		return updateEntity("updateRoom", dto);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RoomDAO#removeRoom(String)
	 */
	@Override
	public boolean removeRoom(String room_id) throws DAOException {
		return removeEntity("removeRoom", room_id);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RoomDAO#findRooms(com.dream.house.entity.RoomDTO)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<RoomDTO> findRooms(RoomDTO dto) throws DAOException {
		return (List<RoomDTO>)getEntitys("findRooms", dto);
	}

	/* (non-Javadoc)
	 * @see com.dream.house.dao.RoomDAO#getRoom(String)
	 */
	@Override
	public RoomDTO getRoom(String id) throws DAOException {
		return (RoomDTO)getEntity("getRoom",id);
	}

	/* (non-Javadoc)
	 * @see cn.com.servyou.base.dao.BaseDAO#getEntityName()
	 */
	@Override
	public String getEntityName() {
		return RoomDTO.class.getCanonicalName();
	}

	@Override
	public RoomDTO getRoomDetail(String id) throws DAOException {
		return (RoomDTO)getEntity("getRoomDetail",id);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<RoomDTO> findRoomsWithBuyRent(RoomDTO dto) throws DAOException {
		return (List<RoomDTO>)getEntitys("findRoomsWithBuyRent",dto);
	}

	@Override
	public boolean updateUseStatus(String id, String status) throws DAOException {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("id", id);
		map.put("status", status);
		
		return updateEntity("updateUseStatus", map);
	}


	@Override
	public boolean locked(String id) throws DAOException {
		
		return updateEntity("locked", id);
	}

	@Override
	public boolean unLocked(String id) throws DAOException {
		
		return updateEntity("unLocked", id);
	}

	@Override
	public boolean removeRecord(String room_id) throws DAOException {
		
		return removeEntity("removeRecord", room_id);
	}
}
